<template>
  <h1>Dept</h1>
  <el-button type="success" @click="doAdd">添加新部门</el-button>
  {{ getDeptByNo(2) }}
  <el-table :data="allDepts" style="width: 100%">
    <el-table-column prop="deptno" label="部门编号" width="180" />
    <el-table-column prop="dname" label="部门名称" />
    <el-table-column prop="loc" label="部门地址" />
  </el-table>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import useDeptStore from '../../../stores/dept.js'

const doAdd = () => {
  deptStore.addDept()
}

const deptStore = useDeptStore()
const { allDepts, getDeptByNo } = storeToRefs(deptStore)
</script>
